home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Interactive 7
/
PC World Interactive 7.iso
/
program
/
cprog.EXE
/
CC_1.ZIP
/
SWAB.C
< prev
next >
Wrap
Text File
|
1980-01-10
|
640b
|
16 lines
#include <errno.h>
extern int abort();
/*
** copy nbytes between from and to, swapping odd and even bytes in the process
*/
swab(from, to, nbytes) char *from, *to; int nbytes; {
char temp;
if(nbytes & 1) abort(EINVAL); /* nbytes must be even */
nbytes >>= 1; /* get count in halfwords */
while(nbytes--) {
temp = *from++; /* temp allows copy to self */
*to++ = *from++;
*to++ = temp;
}
}